package com.lzl.responese;

import com.lzl.constant.CommonStatusEnum;
import lombok.Data;
import lombok.experimental.Accessors;

@Data
@Accessors(chain = true)//链式方式获取（设置值）
public class ResponseResult<T> {

    private int code;

    private String message;

    private T data;



    /**
     * //TODO
     *
     * @description //TODO
     * @author zhaolinlin
     * @createTime 2022/7/30 14:36
     * @param []
     * @return com.lzl.responese.ResponseResult
     */
    public static <T> ResponseResult success(){
        return new ResponseResult().setCode(CommonStatusEnum.SUCCESS.getCode()).setMessage(CommonStatusEnum.SUCCESS.getValue());
    }

    /**
     * //TODO
     *
     * @description //TODO
     * @author zhaolinlin
     * @createTime 2022/7/30 14:38
     * @param date
     * @return com.lzl.responese.ResponseResult
     */
    public static <T> ResponseResult success(T date){
     return new ResponseResult().setCode(CommonStatusEnum.SUCCESS.getCode()).setMessage(CommonStatusEnum.SUCCESS.getValue()).setData(date);
    }

    /**
     * //TODO
     *
     * @description //TODO
     * @author zhaolinlin
     * @createTime 2022/7/30 23:31
     * @param
     * @return com.lzl.responese.ResponseResult
     */
    public static ResponseResult fail() {
        return new ResponseResult().setCode(CommonStatusEnum.FAIL.getCode()).setMessage(CommonStatusEnum.FAIL.getValue());
    }

    public static ResponseResult fail(int code,String message){
        return new ResponseResult().setCode(code).setMessage(message);
    }

    /**
     * //TODO
     *
     * @description //TODO
     * @author zhaolinlin
     * @createTime 2022/8/7 20:11
     * @param data
     * @return com.lzl.responese.ResponseResult
     */
    public static <T> ResponseResult fail(T data) {
        return new ResponseResult().setData(data);
    }





}
